﻿
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Gift.Model;
using Gift.DAL;


namespace WebSite.cn.service
{
    public partial class insuring : BasePage
    {
        DALGoods theGoods = new DALGoods();
        DALNews theNews = new DALNews();
    

        StringBuilder _sbLeftBody01 = new StringBuilder();

        public StringBuilder SbLeftBody01
        {
            get { return _sbLeftBody01; }
        
        }

        StringBuilder _sbLeftBody02 = new StringBuilder();

        public StringBuilder SbLeftBody02
        {
            get { return _sbLeftBody02; }

        }
        protected void Page_Load(object sender, EventArgs e)
        {
            this.GetArticleList();
        }

        public string WriterGoodsHtml()
        {
            StringBuilder sGoodsHtml = new StringBuilder();

            DataTable dtGoods = theGoods.GetList(" isnull(visible,0)=1 and isnull(isSale,0)=1 and termsId in(select id from tbTerms where termsName like '%保险保障%')  order by goodsOrder ").Tables[0];

            for (int i = 0; i < dtGoods.Rows.Count; i++)
            {

          sGoodsHtml.AppendFormat("       <div class=\"card_list left\"> "
                                       +"   <div class='pic' title='{3}'> <img src=\"/uploadfile/product/{0}\"  alt=\"{3}\" /></div> "
                                          +" <div class=\"right\"> <a href=\"{2}\" target='_blank'  > <img src=\"/cn/serviceImages/insuring_card_submit.jpg\"  alt=\"\" /></a>"
                                          +"  <div title='{3}'> {1}</div>  "
                                          +" </div> "
                                        +" </div> "
                                        , dtGoods.Rows[i]["smallPic"].ToString()
                                        , dtGoods.Rows[i]["goodsName"].ToString().Length > 10 ? dtGoods.Rows[i]["goodsName"].ToString().Substring(0, 10) + ".." : dtGoods.Rows[i]["goodsName"].ToString()
                                        , dtGoods.Rows[i]["detailUrl"].ToString() == "" ? "/cn/goodsDetail.html?gid=" + dtGoods.Rows[i]["goodsId"].ToString() : dtGoods.Rows[i]["detailUrl"].ToString()
                                        , dtGoods.Rows[i]["goodsName"].ToString()
                                        );
      
            }
 
            return sGoodsHtml.ToString();

        }

        void  GetArticleList()
        {

            DataTable table = theNews.GetList(10, "typeid in(select typeId from tbNewsType where typeName='保险咨询') and visible=1 and isnew=1", "newsOrder asc, updatetime desc").Tables[0];
            if (table != null)
            {
                int iRowIndex = 0;
                foreach (DataRow row in table.Rows)
                {
                    if (iRowIndex < 5)
                    {
                        _sbLeftBody01.AppendFormat("<li><span> <a href=\"{0}\" target='_blank' title=\"{1}\">{2}</a></span><span class=\"time\">[{3}]</span> </li>"
                                               ,  "/cn/news_01.aspx?tid=" + row["typeid"].ToString() + "&nid=" + row["newsid"].ToString()
                                               , row["newsname"].ToString()
                                               , row["newsname"].ToString().Length > 15 ? fun.Left(row["newsname"].ToString(), 15) + ".." : row["newsname"].ToString()
                                               , row["updatetime"].ToString()
                                               );
                    }
                    else
                    {
                        _sbLeftBody02.AppendFormat("<li><span> <a href=\"{0}\" target='_blank' title=\"{1}\">{2}</a></span><span class=\"time\">[{3}]</span> </li>"
                                                , "/cn/news_01.aspx?tid=" + row["typeid"].ToString() + "&nid=" + row["newsid"].ToString()
                                                , row["newsname"].ToString()
                                                 , row["newsname"].ToString().Length > 15 ? fun.Left(row["newsname"].ToString(), 15) + ".." : row["newsname"].ToString()
                                                , row["updatetime"].ToString()
                                                );
                    }
                    iRowIndex++;
                }
            }
          
          
        }


    }
}